<?php

class mcustomers extends CI_Model {

    private $tbl = "customers";

    public function fetchAll($numb = NULL, $off = NULL) {
        if ($numb == Null && $off == NULL)
            return $this->db->order_by("id", "desc")->get($this->tbl)->result();
        else
            return $this->db->order_by("id", "desc")->get($this->tbl, $numb, $off)->result();
    }

    public function fetchOne($id) {
        return $this->db->where('id', $id)->get($this->tbl)->row();
    }

    public function insert($arr = array()) {
        $this->db->insert($this->tbl, $arr);
    }

    public function update($id, $arr = array()) {
        $this->db->where('id', $id)->update($this->tbl, $arr);
    }

    public function delete($id) {
        $this->db->delete($this->tbl, array('id' => $id));
    }
    
    public function getCusByEmail($email) {
        return $this->db->where('email', $email)->get($this->tbl)->row_array();
    }
    
    public function countCusByEmail($email) {
        return $this->db->where('email', $email)->count_all_results($this->tbl);
    }

}
